package wishes;

import enums.WishType;
import interfaces.AbstractFood;
import interfaces.AbstractWish;
import model.Model;

public class WishToEat extends AbstractWish {
	private AbstractFood food;
	public WishToEat(long startTime, AbstractFood food) {
		super(startTime);
		this.food = food;
	}

	public boolean canBeFulfilled() {
		return food.hasEnoughDishes() && food.hasEnoughIngredients();
	}

	public long getDeadLine() {
		return getStartTime() + Model.ZEIT_STUNDE;
	}

	public boolean fulfill() {
		if (this.canBeFulfilled()) {		
			Model.getInstance().eat(food);
			return Model.getInstance().getWishes().remove(this);
		}
		return false;
	}

	public AbstractFood getFood() {
		return food;
	}

	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("bis ").append(Model.millisToString(getDeadLine()));
		builder.append(" >> Will essen (").append(food.getName()).append(")");
		return builder.toString();
	}


	public WishType getType() {
		return WishType.WishToEat;
	}
}